<ui:composition template="/WEB-INF/templates/customer/base.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<ui:define name="title">Dettagli Pacchetto</ui:define>

	<ui:define name="content">
	<h:form>
		<p:panel rendered="#{! sharedPackageBean.pack.model.valid}"><h2>Il pacchetto non è più valido</h2></p:panel>
		<h:panelGroup rendered="#{sharedPackageBean.pack.model.valid}" >
		
		<p:panelGrid style="width:100%; margin:10px 0">
			<f:facet name="header">
				<p:row>
					<p:column colspan="2">#{sharedPackageBean.pack.model.name}</p:column>
				</p:row>
				<p:row>
					<p:column>Descrizione</p:column>
					<p:column></p:column>
				</p:row>
			</f:facet>

			<p:row>
				<p:column>#{sharedPackageBean.pack.model.description}</p:column>
				<p:column style="text-align: center; width: 250px">
					<p:graphicImage rendered="#{sharedPackageBean.pack.model.image != ''}"
						value="#{sharedPackageBean.pack.model.image}" style="max-width: 200px; max-height: 200px" />
					<div class="ui-widget-header ui-corner-all" style="padding: 3px; text-align: center;">
						Dal
						<h:outputText value="#{sharedPackageBean.pack.date}">
							<f:convertDateTime pattern="dd-MM-yyyy" />
						</h:outputText>
						per #{sharedPackageBean.pack.duration} Notti
					</div>
				</p:column>
			</p:row>
		</p:panelGrid>

		<p:panelGrid style="width:100%; margin:10px 0">
			<f:facet name="header">
				<p:row>
					<p:column colspan="5">Andata</p:column>
				</p:row>
				<p:row>
					<p:column>Nome</p:column>
					<p:column>Descrizione</p:column>
					<p:column>Origine</p:column>
					<p:column>Destinazione</p:column>
					<p:column>Prezzo</p:column>
				</p:row>
			</f:facet>

			<p:row>
				<p:column>
					<h:outputText value="#{sharedPackageBean.pack.going.name}" />
				</p:column>

				<p:column>
					<h:outputText value="#{sharedPackageBean.pack.going.description}" />
				</p:column>

				<p:column>
					<h:outputText value="#{sharedPackageBean.pack.going.origin}" />
				</p:column>

				<p:column>
					<h:outputText value="#{sharedPackageBean.pack.going.destination}" />
				</p:column>

				<p:column>
					<h:outputText value="#{sharedPackageBean.pack.going.price}" />
				</p:column>
			</p:row>

		</p:panelGrid>

		<p:panelGrid style="width:100%; margin:10px 0">
			<f:facet name="header">
				<p:row>
					<p:column colspan="5">Ritorno</p:column>
				</p:row>
				<p:row>
					<p:column>Nome</p:column>
					<p:column>Descrizione</p:column>
					<p:column>Origine</p:column>
					<p:column>Destinazione</p:column>
					<p:column>Prezzo</p:column>
				</p:row>
			</f:facet>

			<p:row>
				<p:column>
					<h:outputText value="#{sharedPackageBean.pack.back.name}" />
				</p:column>

				<p:column>
					<h:outputText value="#{sharedPackageBean.pack.back.description}" />
				</p:column>

				<p:column>
					<h:outputText value="#{sharedPackageBean.pack.back.origin}" />
				</p:column>

				<p:column>
					<h:outputText value="#{sharedPackageBean.pack.back.destination}" />
				</p:column>

				<p:column>
					<h:outputText value="#{sharedPackageBean.pack.back.price}" />
				</p:column>
			</p:row>

		</p:panelGrid>


		<p:dataTable var="schedule" value="#{sharedPackageBean.activityList}"
			style="width:100%; margin:10px 0">
			<f:facet name="header">
       			Attività
       		</f:facet>
			<p:column headerText="Id">
				<h:outputText value="#{schedule.activity.id}" />
			</p:column>

			<p:column headerText="Nome">
				<h:outputText value="#{schedule.activity.name}" />
			</p:column>

			<p:column headerText="Descrizione">
				<h:outputText value="#{schedule.activity.description}" />
			</p:column>

			<p:column headerText="Prezzo">
				<h:outputText value="#{schedule.activity.price}" />
			</p:column>
		</p:dataTable>
		<div style="width: 100%; text-align: right;">
			<p:fragment autoUpdate="true">
				<p:panelGrid columns="3" columnClasses="label, value, message">
					<h:outputLabel value="Seleziona numero partecipanti:" for="quantity" />
					<p:spinner min="1" id="quantity" value="#{sharedPackageBean.pack.quantity}">
						<p:ajax event="change" />
					</p:spinner>
					<h:message for="quantity" />
				</p:panelGrid>

				<p:panelGrid id="total" columns="3">
					<h:outputText value="Totale:" />
					<h:outputText value="#{sharedPackageBean.pack.price} x #{sharedPackageBean.pack.quantity}" />
					<h:outputText value="= #{sharedPackageBean.pack.price * sharedPackageBean.pack.quantity} €" />
				</p:panelGrid>

				<p:commandButton value="Aggiungi a Carrello" action="#{sharedPackageBean.addToCart}" />
				<p:commandButton value="Aggiungi a Giftlist" action="#{sharedPackageBean.addToGiftlist}" />
			</p:fragment>
		</div>
		</h:panelGroup>
		</h:form>
	</ui:define>
</ui:composition>